Help Dr. Maya analyze protein sequences by finding the LCS and its occurrences
Dr. Maya needs to find the Longest Common Subsequence (LCS) between two protein sequences and count its occurrences in proteinA.
proteinA:
proteinB:
LCS: ADH (Length: 3, Occurs: 1 in proteinA)
| A | E | D | F | H | R | ||
|---|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 | 0 | 0 | |
| A | 0 | 1 | 1 | 1 | 1 | 1 | 1 |
| B | 0 | 1 | 1 | 1 | 1 | 1 | 1 |
| C | 0 | 1 | 1 | 1 | 1 | 1 | 1 |
| D | 0 | 1 | 1 | 2 | 2 | 2 | 2 |
| G | 0 | 1 | 1 | 2 | 2 | 2 | 2 |
| H | 0 | 1 | 1 | 2 | 2 | 3 | 3 |
LCS Length: 3, Sequence: ADH
For DP table (m, n lengths)
For DP table
Recursive counting
proteinA:
proteinB:
Example 1: proteinA = ABCDGH, proteinB = AEDFHR → Length: 3, Count: 1, LCS: ADH
Example 2: proteinA = AAAAAA, proteinB = AAXAAA → Length: 5, Count: 6, LCS: AAAAA
For building DP table
For DP table
For recursive counting